

// let timer = null;
// function myInterval(cb, delay) {
//     let interval = () => {
//         cb();
//         timer = setTimeout(interval, delay);  // 递归执行
//     }
//     timer = setTimeout(interval, delay); //触发执行
// }
// myInterval(() => { console.log('I am Jack') }, 1000)


let timer
function loop(callback,delay) {
    let inter = () => {
        callback()
        timer = setTimeout(inter,delay)
    }
    inter()
}
loop(() => { console.log('I am Jack') }, 1000)
